Reproducible Code For Brianna
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.4.0 ✔ purrr 0.3.5
## ✔ tibble 3.1.8 ✔ dplyr 1.0.10
## ✔ tidyr 1.2.1 ✔ stringr 1.5.0
## ✔ readr 2.1.3 ✔ forcats 0.5.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
library(dplyr)
library(ggmap)
## ℹ Google's Terms of Service: <]8;;https://mapsplatform.google.comhttps://mapsplatform.google.com]8;;>
## ℹ Please cite ggmap if you use it! Use `citation("ggmap")` for details.
library(berryFunctions)
##
## Attaching package: 'berryFunctions'
##
## The following object is masked from 'package:dplyr':
##
## between
library(ggthemes)
library(RColorBrewer)
library(gganimate)
library(lubridate)
## Loading required package: timechange
##
## Attaching package: 'lubridate'
##
## The following objects are masked from 'package:base':
##
## date, intersect, setdiff, union
library(transformr)
library(metR)
##
## Attaching package: 'metR'
##
## The following object is masked from 'package:purrr':
##
## cross
library(gganimate)
birds <- read.csv("bird_tracking_copy.csv")
#Data from https://www.kaggle.com/datasets/saikrishna20/bird-tracking
forward_trajectory_6_7 <- read.csv("forward_trajectory_6_7.csv")
#Data from http://enram.github.io/bird-migration-flow-visualization/viz/2/nl-be/index.html
europe_africa <- get_stamenmap(
bbox = c(left = -40.61, bottom = 4.92, right = 41.57, top = 54.37),
maptype = "terrain",
zoom = 4
)
## ℹ Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL.
netherlands <- get_stamenmap(
bbox = c(left = -5.23, bottom = 44.918, right = 18.7, top = 55.6),
maptype = "terrain",
zoom = 6)
## ℹ Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL.
forward_trajectory <- forward_trajectory_6_7 %>%
filter(track_id %in% c(1:22)) %>%
mutate(date_time = ymd_hms(date_time), day.of.week=wday(date_time,label=TRUE))
birds<- birds %>%
mutate(ymd_hms =ymd_hms(date_time)) %>%
mutate(ymd =as.Date(date_time), month = month(date_time,label=TRUE), year = year(date_time))
birds1 <- birds %>%
mutate(longitude1 = lag(longitude),
latitude1 = lag(latitude))
bird_anim <- ggmap(europe_africa) +
geom_point(
data = birds1,
aes(x = longitude, y = latitude, color = bird_name),
alpha = 0.5,
size = 2
) +
scale_color_manual(values = c("red","blue4","purple"))+
transition_reveal(along = ymd) +
labs(title = "Stork Migration",
subtitle = "August 2013-April 2014",
x = "Longitude",
y = "Latitude",
color = "Bird Name",
caption = "Data from Sri Sri Krishina N | Vanessa Leon and Alec Chen") +
shadow_wake(wake_length=0.3,exclude_layer = 2) #want this for point, but not for text
bird_anim
animate(bird_anim, duration=20,end_pause=1,nframes=300,
height=480,width=480)
anim_save("storks.gif")
pink <- ggmap(netherlands) +
geom_point(
data = forward_trajectory,
aes(x = longitude, y = latitude, group = track_id),
alpha = 0.5,
size = 0.3,
color = 'red'
) +
transition_time(date_time) +
labs(title = "European Robin Migration",
subtitle = paste("Day:", "{round(frame_time,0)}"),
x = "Longitude",
y = "Latitude",
caption = "Data from European Network for the Radar Surveillance of Animal Movement | Vanessa Leon and Alec Chen")+
shadow_wake(wake_length=0.3)
#animate(pink,duration=20,end_pause=1,nframes=400)
pink
anim_save("good.gif", height = 440, width = 440)
birds %>%
filter(altitude %in% (0:2600)) %>%
ggplot(aes(x=speed_2d, y=altitude)) +
geom_point(size=0.3, color="darkgreen") +
labs(y="Altitude (ft)",x="Speed (mph)",title="Bird altitude compared to speed",caption="Alec Chen and Vanessa Leon | Data from Sri Sai Krishna N") +
facet_wrap(~bird_name) +
theme(panel.background = element_rect(fill='beige',color='beige'),
plot.background = element_rect(fill = 'beige', color ='beige'))+theme(
strip.background = element_rect(
color="grey", fill="#FCC907", size=1.5, linetype="solid"
)
)
## Warning: The `size` argument of `element_rect()` is deprecated as of ggplot2 3.4.0.
## ℹ Please use the `linewidth` argument instead.
## Warning: Removed 368 rows containing missing values (`geom_point()`).